from django.db import models

# Create your models here.
class StudentModel(models.Model):
    name = models.CharField(max_length=100)
    age = models.IntegerField()
    sex= models.BooleanField(default=True)
    address = models.CharField(max_length=100)
    phone_first = models.CharField(max_length=12,blank=True, null=True)
    phone_second = models.CharField(max_length=12,blank=True, null=True)
    number=models.CharField(max_length=60,unique=True)#学号
    class_info = models.ForeignKey('ClassModel',on_delete=models.CASCADE)
    teacher_info= models.ForeignKey('StaffModel',on_delete=models.CASCADE,verbose_name='班主任')
    class Meta:
        db_table = 'student'

class ClassModel(models.Model):
    name = models.CharField(max_length=100)
    teacher_info = models.ForeignKey('StaffModel',on_delete=models.CASCADE,verbose_name='班主任')
    grade = models.CharField('年级', max_length=20)  # 例如"2023级"
    score=models.IntegerField(default=100)
    class Meta:
        db_table = 'class'


class StaffModel(models.Model):
    name = models.CharField(max_length=100)
    age = models.IntegerField()
    sex= models.BooleanField(default=True)
    phone=models.CharField(max_length=12)
    #职务
    position = models.CharField(max_length=100)
    is_excite= models.BooleanField(default=True)
    class Meta:
        db_table = 'staff'


#成绩表
class ScoreModel(models.Model):
    #数学 英语 语文
    student = models.ForeignKey('StudentModel',on_delete=models.CASCADE)
    class_name=models.ForeignKey('ClassModel',on_delete=models.CASCADE)#这个冗余吗
    exam_type=models.CharField(max_length=10)#考试类型
    math =models.DecimalField(max_digits=5,decimal_places=2)
    english =models.DecimalField(max_digits=5,decimal_places=2)
    chinese =models.DecimalField(max_digits=5,decimal_places=2)
    score = models.IntegerField(default=0)
    class Meta:
            db_table = 'score'

